<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>我的收藏</title>
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <style media="screen">
        .wrap {
            width: 100%;
            padding: 0 15px;
            box-sizing: border-box;
            overflow: hidden;
        }

        .nodata_bg {
            width: 70px;
            height: 70px;
            background: url(../../image/collection_nodata.png) no-repeat;
            background-size: 100% 100%;
            margin: 0 auto;
            margin-top: 26px;
        }

        .wrap .text {
            text-align: center;
            width: 100%;
            height: 15px;
            line-height: 15px;
            font-size: 14px;
            margin-top: 15px;
            font-family: PingFang SC;
            font-weight: 400;
            color: #666666;
        }

        .wrap .goindex {
            width: 210px;
            height: 40px;
            background: linear-gradient(-90deg, #7619EC, #A429F3);
            border-radius: 20px;
            margin: 0 auto;
            margin-top: 20px;
            line-height: 15px;
            font-size: 14px;
            font-family: PingFang SC;
            font-weight: 400;
            color: #fff;
            line-height: 40px;
            text-align: center;
        }

        .wrap .jingxuan {
            width: 100%;
            padding: 0 110px;
            box-sizing: border-box;
            margin-top: 20px;
            display: flex;
            justify-content: space-between;
            overflow: hidden;
        }

        .wrap .jingxuan span:nth-child(1) {
            display: flex;
            height: 1px;
            background: #333333;
            margin-top: 8px;
            width: 15px;
        }

        .wrap .jingxuan span:nth-child(2) {
            width: auto;
            height: 17px;
            font-size: 14px;
            font-family: PingFang SC;
            font-weight: 400;
            color: #333333;
            line-height: 17px;
        }

        .wrap .jingxuan span:nth-child(3) {
            display: flex;
            height: 1px;
            background: #333333;
            margin-top: 8px;
            width: 15px;
        }

        .article_recommend {
            width: 100%;
            overflow: hidden;
        }

        .article_recommend .head {
            width: 100%;
            padding: 0 100px;
            overflow: hidden;
            display: flex;
            justify-content: space-between;
        }

        .content {
            width: 100%;
            overflow: hidden;
        }

        .content ul {
            width: 100%;
            margin-top: 5px;
            overflow: hidden;
        }

        .content ul li {
            width: 49%;
            background-color: #fff;
            padding: 5px;
            float: left;
            margin-left: 2%;
            margin-top: 10px;
            box-sizing: border-box;
            overflow: hidden;
        }

        .content ul li:nth-child(2n+1) {
            margin-left: 0;
        }

        .content ul li>.goods_picture {
            width: 100%;
            height: 155px;
            /*background-color: red;*/
        }

        .content ul li>.goods_picture img {
            display: block;
            width: 100%;
            height: 100%;
        }

        .content ul li>.intro {
            width: 100%;
            overflow: hidden;
        }

        .content ul li>.intro span:first-child {
            width: 100%;
            overflow: hidden;
            margin-top: 3px;
            font-size: 12px;
        }

        .content ul li>.intro span:first-child img {
            display: inline-block;
            margin-top: 2px;
            width: 25px;
            height: 12px;
            margin-right: 2px;
        }

        .content ul li>.price {
            width: 100%;
            overflow: hidden;
            display: flex;
            justify-content: space-between;
            margin-top: 8px;
        }

        .content ul li>.price .price_item {
            display: flex;
            width: auto;
        }

        .content ul li>.price .price_item:last-child {
            height: 15px;
            font-size: 14px;
            font-family: PingFang SC;
            font-weight: 400;
            color: #999999;
            line-height: 15px;
        }

        .content ul li>.price .price_item span:nth-child(1) {
            width: auto;
            height: 15px;
            font-size: 10px;
            font-family: PingFang SC;
            font-weight: 400;
            color: #999999;
            line-height: 17px;
        }

        .content ul li>.price .price_item span:nth-child(2) {
            width: auto;
            height: 15px;
            font-size: 10px;
            font-family: PingFang SC;
            font-weight: 400;
            color: #FF4242;
            line-height: 17px;
        }

        .content ul li>.price .price_item span:nth-child(3) {
            width: auto;
            height: 15px;
            font-size: 14px;
            font-family: PingFang SC;
            font-weight: 400;
            color: #FF4242;
            line-height: 15px;
        }
    </style>
</head>

<body>
    <div id="app">
        <div class="wrap">
            <div class="nodata_bg"></div>
            <div class="text">你还没有收藏任何内容~</div>
            <div class="goindex" @click='openIndex()'>去首页逛逛吧~</div>
            <div class="jingxuan"><span></span><span>为您精选</span><span></span></div>
            <div class="article_recommend">
                <div class="content">
                    <ul>
                        <li v-for='item in GuessLoveData' @click='openGoodsDtailsPage(item.goodsId)'>
                            <div class="goods_picture"><img :src="item.mainPic" v-cache-src="item.mainPic" alt=""></div>
                            <div class="intro">
                                <span class="aui-ellipsis-2" v-if='item.shopType==1'><img src="../../image/tm.png" alt="">{{item.dtitle}}</span>
                                <span class="aui-ellipsis-2" v-else><img src="../../image/tb_search.png" alt="">{{item.dtitle}}</span>
                            </div>
                            <div class="price">
                                <div class="price_item"><span>券后</span><span>￥</span><span>{{item.actualPrice}}</span></div>
                                <div class="price_item">已售{{item.monthSales}}</div>
                            </div>
                        </li>
                        <!-- <li>
                            <div class="goods_picture"></div>
                            <div class="intro"><span class="icon"><img src="" alt=""></span>脖枕充气U型枕头护颈枕颈椎枕脖子靠枕坐车飞机...</div>
                            <div class="price">
                                <div class="price_item"><span>券后</span><span>￥</span><span>99</span></div>
                                <div class="price_item">已售1.86万</div>
                            </div>
                        </li> -->
                    </ul>
                </div>
            </div>
        </div>
    </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/vue.js"></script>
<script type="text/javascript" src="../../script/cling.js"></script>
<script type="text/javascript">
    apiready = function() {
        /**
         * [注册一个全局自定义指令 `V-   cache-src`]
         * @param  {[type]} el      [需要图片缓存的元素]
         * @param  {[type]} binding [服务器图片对象数据]
         * @return {[type]}         [服务器图片地址]
         */
        Vue.directive('cache-src', function(el, binding) {
            if (binding) {
                setTimeout(function() {
                    api.imageCache({
                        url: binding.value,
                        thumbnail: false
                    }, function(ret, err) {
                        if (ret && ret.status) {
                            el.setAttribute("src", ret.url);
                        }
                    });
                }, 100);
            }
        });
        vm.getOaid()
        if (api.systemType == 'android') {
            if (api.systemVersion >= 10) {
                vm.GuessLoveData = [];

            } else {
                vm.GuessLoveData = [];
                vm.getBottomlist('IMEI', api.deviceId, 3);
            }
        } else {
            vm.GuessLoveData = [];
            var idfa = api.require('idfa');
            idfa.getIDFA(function(ret, err) {
                if (ret.status) {
                    vm.getBottomlist('IDFA', ret.value, 3);
                }
            });

        }

        vm.initRefresh();
        vm.bottomLoad();
    }
    var vm = new Vue({
        el: '#app',
        data: {
            pageId: 1,
            oaid: '',
            GuessLoveData: []
        },
        methods: {
            getOaid: function() {
                var readId = api.require('readId');
                readId.readOaId(function(ret, err) {
                    if (ret.status) {
                        vm.oaid = ret.data;
                        vm.getBottomlist('OAID', vm.oaid, 3);
                    }

                })
            },
            /**
             *
             * 获取精选
             * @return {[type]} [description]
             */
            getBottomlist: function(deviceType, deviceValue, type, isClick) {
                if (isClick) {
                    vm.pageId += 1;
                } else { // 下拉刷新 或者 初次加载
                    vm.pageId = 1;
                }
                cl.openLoading();
                api.ajax({
                    url: cl.apiServer + 'tb/getGoodThing',
                    method: 'post',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8',
                        token: cl.userToken
                    },
                    data: {
                        body: {
                            deviceType: deviceType,
                            deviceValue: deviceValue,
                            pageId: vm.pageId,
                            pageSize: 10,
                            type: type,
                            version:cl.deviceInfo().appVersion,
                            mobileInfo:cl.systemType()
                        }
                    }
                }, function(ret, err) {
                    // alert(JSON.stringify(ret));
                    if (ret) {
                        if (ret.code == 0) {
                            cl.closeLoading();
                            if (ret.data.length >= 10) {
                                vm.no_more = false;
                                vm.GuessLoveData = vm.GuessLoveData.concat(ret.data);
                            } else if (ret.data.length == 0) {
                                vm.no_more = true;
                            } else {
                                vm.GuessLoveData = vm.GuessLoveData.concat(ret.data);
                            }
                        }
                    }
                });
            },
            //下拉刷新
            initRefresh: function() {
                cl.openRefresh(function() {
                    if (api.systemType == 'android') {
                        if (api.systemVersion >= 10) {
                            vm.GuessLoveData = [];
                            vm.getBottomlist('OAID', vm.oaid, 3);
                        } else {
                            vm.GuessLoveData = [];
                            vm.getBottomlist('IMEI', api.deviceId, 3);
                        }
                    } else {

                    }
                })
            },
            //上拉加载
            bottomLoad: function() {
                cl.scrollBottom(function() {
                    if (api.systemType == 'android') {
                        if (api.systemVersion >= 10) {
                            vm.getBottomlist('OAID', vm.oaid, 3, true);
                        } else {
                            vm.getBottomlist('IMEI', api.deviceId, 3, true);
                        }
                    } else {


                      vm.GuessLoveData = [];
                      var idfa = api.require('idfa');
                      idfa.getIDFA(function(ret, err) {
                          if (ret.status) {
                              vm.getBottomlist('IDFA', ret.value, 3,true);
                          }
                      });

                    }
                })
            },
            openGoodsDtailsPage: function(id) {
                cl.openWin({
                    name: '../main/goods_deatils',
                    pageParam: {
                        id: id
                    }
                })
            },
            openIndex: function() {
                cl.closeToWin({
                    name: 'root'
                });
                api.sendEvent({
                    name: 'backindex'
                });
            }
        }
    });
</script>

</html>
